#include<stdio.h>
#include<math.h>
#include<string.h>
int htoi(char []);
int main()       /* converting string of hex digits to decimal equivalent */
{
 char p[20];
 gets(p);
 printf("number in decimal : %d",htoi(p));
 return 0;
}

int htoi(char p[])
{
  int i,j,len,num=0;
  len=strlen(p);
  for(i=len-1,j=0;i>=0 && (p[i]!='x'|| p[i]!='X');i--,j++)
    {
      if(isdigit(p[i]))
        num=num+((p[i]-'0')*(int)(pow(16,j)));
      else
        switch(p[i])
        {
          case 'A':
          case 'a':
                   num=num+(10*pow(16,j));
                   break;
          case 'B':
          case 'b':
                          
                   num=num+(11*pow(16,j));
                   break;
          case 'c':
          case 'C':
                   
                   num=num+(12*pow(16,j));
                   break;
          case 'd':
          case 'D':
                   
                   num=num+(13*pow(16,j));
                   break;
          case 'e':
          case 'E':
                                   
                   num=num+(14*pow(16,j));
                   break;
          case 'f':
          case 'F':
                     
                   num=num+(15*pow(16,j));
                   break;
   
           
        }
    }
  return num;
}

